package com.info.zhiduoduo.common.validator;

import com.google.common.collect.Lists;

import java.util.List;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class StringInValidator implements ConstraintValidator<StringIn, String> {

	private List<String> list;

	@Override
	public void initialize(StringIn constraintAnnotation) {
		list = Lists.newArrayList(constraintAnnotation.value());
	}

	@Override
	public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
		return list.contains(value);
	}
}
